<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<script type="text/javascript" src="../layui/layui.js"></script>
</head>
<body>
	<div>
		<form id="form_xiuGaiMiMa" class="layui-form" action=""
			onsubmit="return false" lay-filter="form_xiugaimima">
			<div class="layui-form-item">
				<label class="layui-form-label">原密码</label>
				<div class="layui-input-inline">
					<input type="" name="oldPas" lay-verify="required"
						placeholder="请输入原密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码</label>
				<div class="layui-input-inline">

					<input type="password" name="newPas" lay-verify="required"
						placeholder="请输入新密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">再次输入</label>
				<div class="layui-input-inline">
					<input type="password" name="twoPas" required lay-verify="required"
						placeholder="再次输入新密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit=""
						lay-filter="update">保存修改</button>
				</div>
			</div>
		</form>
	</div>
	<script>
		layui.use('form', function(){
		  var form = layui.form;
		  var $ = layui.$;
		  form.on('submit(update)', function(data){
			var id = sessionStorage.getItem("userId");
			if(id==null){
				alert("用户身份过期,请从新登陆!")
				location.href="/login.html";
			}
		  	var canShu = $("#form_xiuGaiMiMa").serialize()+"&Id="+id;
			  $.post("/users/updUserPasById",canShu,function(res){
			 		if(res.code=="0"){
				   		layer.msg(res.msg,function(){
							sessionStorage.removeItem("userId");
							location.href="/login.html"
						});
					}else if(res.code=="1"){
				   		layer.msg(res.msg);
					}else if(res.code=="2"){
				   		layer.msg(res.msg);
					}else{
						layer.msg(res.msg);
					}
			  },"json");
			  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
			});
		  //各种基于事件的操作，下面会有进一步介绍
		});
</script>
</body>
</html>